<template>
  <div>
    <el-table
      :data="table.tableData"
      size="mini"
      style="width: 100%">
      <el-table-column align="center" type="selection"  width="40">
      </el-table-column>
      <el-table-column align="center" type="index"  width="50">
      </el-table-column>
      <el-table-column align="center" prop="createTime" label="日期" width="165">
        <template slot-scope="scope">
          <i class="el-icon-time"></i>
          <span style="margin-left: 10px">{{ scope.row.createTime }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="name" label="名称" width="100">
        <template slot-scope="scope">
          {{ scope.row.name }}
        </template>
      </el-table-column>
      <el-table-column align="center" prop="permission" label="permission" width="100">
        <template slot-scope="scope">
          {{ scope.row.permission }}
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page.sync="table.pagination.currentPage"
      :page-sizes.sync="table.pagination.pageSizes"
      :page-size.sync="table.pagination.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total.sync="table.pagination.total" style="text-align: right">
    </el-pagination>
  </div>
</template>

<script>
import {fetch} from '@/utils/http'
export default {
  data () {
    return {
      table: {
        tableData: [],
        pagination: {
          currentPage: 1,
          pageSizes: [5, 10, 15],
          pageSize: 5,
          total: 20
        },
        methods: {
        }
      }
    }
  },
  mounted: function () {
    this.fetch()
  },
  methods: {
    handleSizeChange () {},
    handleCurrentChange () {},
    fetch (page = {
      page: 1,
      limit: 5
    }) {
      // Object.assign(page, this.table.cacheSearchData)
      fetch('/upms/permission/page', page).then((res) => {
        if (res.status === 200) {
          this.table.tableData = res.data.rows
          this.table.pagination.total = res.data.total
          this.table.pagination.currentPage = page.page
          this.table.pagination.pageSize = page.limit
          this.$message(res.message)
        } else {
          this.$message.error(res.message)
        }
      })
    }
  }
}
</script>
